﻿using System.Windows.Media;

namespace Red.Controls.Diagrams
{
    /// <summary>
    /// This converter is used to set node texts foreground colors.
    /// It adjusts colors to keep high contrast between background and foreground.
    /// It is done to provide full readability despite the background color.
    /// </summary>
    public class NodeColorConverter
    {
        #region Public methods

        public static Brush GetForegroundBrush( Color backgroundBrushColor )
        {
            var Y = 0.2126 * backgroundBrushColor.ScR + 0.7152 * backgroundBrushColor.ScG + 0.0722 * backgroundBrushColor.ScB;
            return Y > 0.4 ? Brushes.Black : Brushes.White;
        }

        #endregion Public methods
    }
}
